package com.kongwg.exer2;

public class CheckAccount extends Account {
	int overdraft;
	
	public CheckAccount(int id, double balance, double annualInterestRate,int overdraft){
			super(id,balance,annualInterestRate);
			this.overdraft = overdraft;
	}
	
	
	public int getOverdraft() {
		return overdraft;
	}


	public void setOverdraft(int overdraft) {
		this.overdraft = overdraft;
	}


	@Override
	public void withdraw(double amount){
		
		if(amount < balance){
			balance -= amount;
		}else if(amount >balance){
			double b = amount-balance;
			if(b < overdraft){
				balance = 0;
				overdraft -=b;
				
//				super.withdraw(amount);
				
				
			}else{
				System.out.println("超过可透支额的限额");
			}
			
			
		}
	}
}
